'use strict'
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  devServer: {
    host: '192.168.3.135',
    port: '4399',
    open: true,
    proxy: {
      '/user': {
        target: 'http://localhost:3000/user',
        changeOrigin: true,
        pathRewrite: {
          '^/user': ''
        }
      },
      '/article': {
        target: 'http://localhost:3000/article',
        changeOrigin: true,
        pathRewrite: {
          '^/article': ''
        }
      }
    }
  },
  configureWebpack: {
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },
  chainWebpack(config) {
    config.module.rule('svg').exclude.add(resolve('src/icons')).end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
}
